FROM apache/skywalking-base:latest AS build

WORKDIR skywalking

RUN set -eux; \
    rm -rf "config"; rm -rf "oap-libs"; \
    rm -rf "webapp";

FROM openjdk:8-jre-alpine

MAINTAINER "lizhiyong <george510257@126.com>"

COPY --from=build /skywalking /skywalking

ENV SERVICE_NAME="csg-service-gateway" \
    SERVICE_PORT="9080" \
    SKYWALKING_SERVER="skywalking-oap-server:12800"

ARG JAR_FILE
ADD target/${JAR_FILE} /csg/web.jar

EXPOSE ${SERVICE_PORT}

ENTRYPOINT ["java", "-javaagent:/skywalking/agent/skywalking-agent.jar", "-Dskywalking.agent.service_name=${SERVICE_NAME}", "-Dskywalking.collector.backend_service=${SKYWALKING_SERVER}", "-jar", "/csg/web.jar"]